<?php

namespace Drupal\shushengyuan\Schemas;

use Exception;

/**
 * @OA\Schema(
 *   schema="ProductPurchaseItem",
 *   type="object",
 *   description="ProductPurchaseItem",
 *   allOf={
 *       @OA\Schema(ref="#/components/schemas/ProductItem"),
 *   }
 * )
 */
class ProductPurchaseItem extends ProductItem {

  protected function getPrice() {
    return parent::getPrice();
    //需要入驻商家才可以进货
    //需要计算商家折扣
    //按商品分类计算 如果分类未设置按店铺级别计算
    try {
      $level = shusy_category_rebate_product_level($this->getUid(), $this->entity->id);
      return $this->wrapper->purchase->price->amount->value() * $level;
    } catch (Exception $exception) {
      watchdog_exception(__FUNCTION__, $exception);
      return 0;
    }
  }

}
